package com.easyctrl.adapter;

import java.util.ArrayList;

import com.easyctrl.ldy.activity.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class TextSelectAdapter extends BaseAdapter {

	private String[] list;
	private Context mContext;

	public TextSelectAdapter(Context context, String[] list) {
		this.list = list;
		mContext = context;
	}

	@Override
	public int getCount() {
		return list == null ? 0 : list.length;
	}

	@Override
	public Object getItem(int arg0) {
		return list[arg0];
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View converVew, ViewGroup parent) {

		String text = list[position];

		ViewHolder holder;

		if (converVew == null) {
			holder = new ViewHolder();
			converVew = LayoutInflater.from(mContext).inflate(
					R.layout.text_select, parent, false);
			holder.textView = (TextView) converVew
					.findViewById(R.id.textSelect);
			converVew.setTag(holder);
		} else {
			holder = (ViewHolder) converVew.getTag();
		}

		holder.textView.setText("" + text);

		return converVew;
	}

	private class ViewHolder {
		public TextView textView;
	}
}
